
// BBViewer.h : main header file for the BBViewer application
//
#pragma once

#ifndef __AFXWIN_H__
	#error "include 'stdafx.h' before including this file for PCH"
#endif

#include "resource.h"       // main symbols
#include "UIConst.h"
#include "../_inc_app/SupportLang.h"
#include "../_inc_app/SupportImage.h"


#define GET_STRING(a, k, d)		theApp.GetUIString(a, k, d)
// CBBViewerApp:
// See BBViewer.cpp for the implementation of this class
//

class CBBViewerApp : public CWinAppEx
{
public:
	CBBViewerApp();


// Overrides
public:
	virtual BOOL InitInstance();
	BOOL InitW2Sock(WSADATA * lpwsaData);

	void GetLanguageSupport();

	
// Implementation
	UINT  m_nAppLook;
	BOOL  m_bHiColorIcons;

	virtual void PreLoadState();
	virtual void LoadCustomState();
	virtual void SaveCustomState();

	DECLARE_MESSAGE_MAP()
	virtual int ExitInstance();


public:
	DWORD dwScreenWidth;
	DWORD dwScreenHeight;
	DWORD dwWinWidth;
	DWORD dwWinHeight;
	DWORD dwDisplayWidth;
	DWORD dwDisplayHeight;
	DWORD dwDefaultWidth;
	DWORD dwDefaultHeight;

	int nViewerMode;
	BOOL bDownSize;

	int m_nDemo;

	DWORD dwAudioFormat;
	DWORD dwAudioFrequency;
	DWORD dwAudioBitPerSample;

	int m_nScreenSaveTimeout;
	TCHAR m_tzLogPath[MAX_PATH];

	CSupportLang m_SupportLang;
	CSupportImage m_SupportImage;
	CStringArray m_sarrLangPath;
	CStringArray m_sarrLang;
	CString m_strImageRoot;
	CString m_strImageInfoFileName;


	//path
	CString m_strModulePath;		//folder path which BBViewer.exe belongs to
	CString m_strOptionPath;		//Option.ini path
	CStringArray m_sarrOptionPath;
	CString m_strOptionRoot;		//folder path which Option folder belongs to
	CString m_strLangPath;
	CString m_strMyDocumentRoot;
	CString m_strBackupRoot;


	CArray <LPST_BMP_INFO, LPST_BMP_INFO> BmpInfo;
	CArray <LPST_WND_POS, LPST_WND_POS> WndPos;

	void SetDlgSize();
	void InitDlgSize();

	CString GetUIString(CString strAppName, CString strKeyName, CString strDefaultString);
	void WriteRegString(CString strAppName, CString strKeyName, CString strValue);
	void WriteRegInt(CString strAppName, CString strKeyName, int nValue);

	void InitDocPath();
	CString GetDocPath() { return m_strMyDocumentRoot; };

	void InitLogPath();
	TCHAR *GetLogPath() {  return m_tzLogPath; };

	void InitBackupPath();
	CString GetBackupPath() { return m_strBackupRoot; };

	void SetLangSupport(BOOL bAuto, CString strLang);
	BOOL GetLangSupport(CString &strLang, LANGID &langID);

	BOOL InitGUI();

	void LoadWinInfo();
	void UnloadWinInfo();
	void LoadImage();
	void UnloadImage();

	BOOL GetLanguageList(int nIndex, CString &strLang);
	BOOL GetSkinList(int nIndex, CString &strSkin);
	int GetSelectSkinList();
	void SetSelectSkinList(int nIndex);

	void InitOptionPath();
	CString GetOptionPath() { return m_strOptionPath; };
	CString GetOptionPath(int nIndex);
	int GetOptionPathCount() { return m_sarrOptionPath.GetSize(); };

	void InitOption();
	void GetLatestPath(TCHAR *tzLatestPath, DWORD dwSize);
	void WriteLatestPath(TCHAR *tzLatestPath, DWORD dwSize);
	int GetDemoMode();

	void SetWindowPosition(CWnd *pWnd, int cx, int cy, CRect rtWnd, CRect rtStickTo, BOOL bShow = TRUE, BOOL bVCenter = FALSE, BOOL bHCenter = FALSE);

	void ShowSplachScreen(BOOL bShow);
	CString GetLogoPath();


	//////////////////////////////////////////////////////////////////////////
	//path info

private:
	void FindLanguagePath(CString strPath);
};

extern CBBViewerApp theApp;
